package com.xyhua.validator.controller;

import com.xyhua.validator.ValidationUtils;
import com.xyhua.validator.entity.UserEntity;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * description: IndexController <br>
 * date: 2020/3/25 4:02 下午 <br>
 * author: huaxiansheng <br>
 * version: 1.0 <br>
 */

@RestController
public class IndexController {


    @PostMapping(value = "index")
    //@Transactional(rollbackFor=Exception.class)
    public String add(@RequestBody @Validated UserEntity userEntity) {
        return "hello";
    }

    @PostMapping(value = "index2")
    //@Transactional(rollbackFor=Exception.class)
    public String add2(@RequestBody UserEntity userEntity) {
        ValidationUtils.validateEntity(userEntity);
        return "hello";
    }

}
